﻿// See https://aka.ms/new-console-template for more information
using System.Reflection;
using TestReadonly;
using static System.Console;

Title = "C#中const和readonly关键字";


WriteLine(TestConst.constNum);

WriteLine(TestConst.staticReadonlynum);

TestConst tc = new TestConst();
//tc.readonlyNum = 2;
tc.listNums.Add(2);

foreach (var item in tc.listNums )
{
    WriteLine(item);
}



Student st = new Student();
WriteLine(st.GetId());

FieldInfo fieldInfo = typeof(Student).GetField("ID", BindingFlags.Instance | BindingFlags.NonPublic);

fieldInfo.SetValue(st, 2);

WriteLine(st.GetId());
WriteLine(st.Grade);

//st.Grade = 3;
//typeof(Student).GetProperty("Grade", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(st, 3);




ReadKey();